package com.frogs.ucenter.v1.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.frogs.framework.base.web.BaseController3;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.api.response.FailResponse;
import com.frogs.system.web.api.response.Response;
import com.frogs.system.web.exception.AppBaseException;
import com.frogs.ucenter.v1.request.TagBaseInfoListRequest;
import com.frogs.ucenter.v1.service.TagBaseInfoService;
import com.frogs.ucenter.v1.util.ApiConstants;

@Controller(ApiConstants.VERSION + "tagBaseInfoController")
@RequestMapping("/" + ApiConstants.VERSION )
public class TagBaseInfoController extends BaseController3 {
	
    @Resource(name=ApiConstants.VERSION + "tagBaseInfoService")
    private TagBaseInfoService tagService;

    private static final String ROOT = "/tag";
    private static final String TAG_LIST = ROOT + LIST;
    
    @RequestMapping(TAG_LIST)
    public Response tagList(HttpServletRequest httpRequest){
    	Request request = new TagBaseInfoListRequest(); 
    	Response response;
    	try {
    		request.parse(httpRequest);
    		response = tagService.listTags(request);
    		response.setTip("查询列表成功!");
    	} catch(Exception e) {
    		response = new FailResponse();
			if (e instanceof AppBaseException) {
				response.setTip(e.getMessage());
			} else {
				response.setTip("errro message" + e.getMessage());
			}
    	}
    	return response;
    }

}